<?php
class Cms_Mail_Email{
	public function sendMail($emails=array(),$template,$params=array(),$subject="",$name="")
	{
		
		//emails = array( 'name' => 'email')
		//$templates : 'order.phtml',.....
		//$subject : mail title,
		//$name : don't need
		
		$configs = array(
				'auth'=> 'login',
				'username'=>'trandinhhoanghac',
				'password'=>'iamabadboy',
				'ssl'=> 'tls',
				//'port'=>465,
				
		);
		$gate = new Zend_Mail_Transport_Smtp('smtp.gmail.com',$configs);
		Zend_Mail::setDefaultTransport($gate);
		$mail = new Zend_Mail('UTF-8');		
		$html = new Zend_View();
		$html->setScriptPath(APPLICATION_PATH."/../public/templates/mails/");		
		if(count($params)>0){
			foreach ($params as $key => $value)
			$html->assign($key,$value);
		}		
		$body=$html->render($template);
		$mail->setBodyHtml($body);
		$mail->setFrom('trandinhhoanghac@gmail.com','Hoàng Hạc');
		$mail->addTo($emails,$name);
		$mail->setSubject($subject);
		$mail->send($gate);
		
		
	}
}
